package com.hjx.service.impl;

import com.hjx.entity.SysMenu;
import com.hjx.mapper.SysMenuMapper;
import com.hjx.service.SysMenuService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>Title:</p>
 * <p>Description:</p>
 *
 * @author hjx
 * @date 2020/6/17 - 10:02
 */
@Service
@Transactional
public class SysMenuServiceImpl implements SysMenuService {
    @Resource
    SysMenuMapper sysMenuMapper;
    /**
     * 根据MID单查权限
     * @param mid
     * @return 单查出来的权限对象
     */
    @Override
    public SysMenu findOne(String mid) {
        if (!StringUtils.isEmpty(mid)&&!StringUtils.isBlank(mid)) {
            return sysMenuMapper.findOne(mid);
        }
        return null;
    }

    @Override
    public List<SysMenu> findAll() {
        return sysMenuMapper.findAll();
    }

    @Override
    public boolean insert(SysMenu sysMenu) {
        return sysMenuMapper.insert(sysMenu);
    }

    @Override
    public boolean insertBatch(SysMenu[] sysMenus) {
        return sysMenuMapper.insertBatch(sysMenus);
    }

    @Override
    public boolean delete(String mid) {
        if (!StringUtils.isEmpty(mid)&&!StringUtils.isBlank(mid)) {
            return sysMenuMapper.delete(mid);
        }
        return false;
    }

    @Override
    public boolean update(SysMenu sysMenu) {
        return sysMenuMapper.update(sysMenu);
    }

    @Override
    public List<SysMenu> findByParentId(String parentId) {
        if (!StringUtils.isEmpty(parentId)&&!StringUtils.isBlank(parentId)) {
            return sysMenuMapper.findByParentId(parentId);
        }
        return null;
    }
}
